﻿@model Rail.Net.Core.Model.Nonpersistent.SearchModel
@using Rail.Net.Common.Resources

@{
    ViewBag.Title = "eRailnet - " + Global.Main_BreadCrumb_Selection;
}

<div id="selection-content">
    <script src="@Url.Content("~/Scripts/jquery.regex.js")" type="text/javascript"></script>    
    <script src="@Url.Content("~/Scripts/jquery.blockUI.js")" type="text/javascript"></script>
    
    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.ui.timepicker.addon.js")"></script>
    @if (@Session["Culture"].ToString() == "de-AT") {
        <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.ui.datepicker-de.js")"></script>
    }
    else if (@Session["Culture"].ToString() == "en-US") {
        <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.ui.datepicker-en.js")"></script>
    }
    else if (@Session["Culture"].ToString() == "fr-FR")
    {
        <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.ui.datepicker-fr.js")"></script>
    }
    else if (@Session["Culture"].ToString() == "it-IT")
    {
        <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.ui.datepicker-it.js")"></script>
    }
    
    <script type="text/javascript">
        var travelersCount = @(Model.Travelers.Count);
        var addTravelerText = '@(Global.Main_Selection_InsertTraveler)';
        var removeTravelerText = '@(Global.Main_Selection_RemoveTraveler)';
        var region = '@Session["Culture"].ToString().Replace("-AT", "").Replace("-FR", "").Replace("-IT", "").Replace("en-US", "")';
    </script>
    <script src="@Url.Content("~/Scripts/selection.js")" type="text/javascript"></script>  
    


    @{ Html.EnableClientValidation(); }
    @using (Ajax.BeginForm("Offers", "Ticket", new { }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "offers-content", InsertionMode = System.Web.Mvc.Ajax.InsertionMode.Replace, OnBegin = "OffersBegin", OnSuccess = "OffersSuccess", OnFailure = "OffersFailure" }, new { id = "SelectionForm" }))
    {
        @Html.ValidationSummary(true)
        <fieldset>
            <legend>@Global.Main_BreadCrumb_Selection</legend>
            @Html.EditorFor(model => model.FromStation)
            @*@Html.HiddenFor(model => model.FromStationName)*@
            @Html.EditorFor(model => model.ToStation)
            @*@Html.HiddenFor(model => model.ToStationName)*@
            @Html.EditorFor(model => model.FromDate)
            @Html.EditorFor(model => model.ToDate)

            <div class="efield" style="height: 100%">
                <div class="elabel">
                    @Global.MainModel_Traveler:
                </div>
                <div class="einput">
                    <table id="Travelers">
                    @{
        for (var index = 0; index < Model.Travelers.Count; index++)
        {
                            <tr id="Traveler_@(index)">                            
                                <td>@Html.EditorFor(model => model.Travelers[index].Age)</td>
                                <td>@Html.EditorFor(model => model.Travelers[index].Discount)</td>
                                <td>
                                    @if (index == 0)
                                    {
                                        <input type="submit" id="AddNewTraveler_@(index)" name="AddNewTraveler_@(index)" value="@(Global.Main_Selection_InsertTraveler)" />
                                    }
                                    else
                                    {
                                        <input type="submit" id="RemoveTraveler_@(index)" name="RemoveTraveler_@(index)" value="@(Global.Main_Selection_RemoveTraveler)" />
                                    }
                                </td>
                            </tr>
        }            
                    }
                    </table>
                </div>                
            </div>
        
            @Html.EditorFor(model => model.PaymentType)
        </fieldset>
        <div class="center">
            <input type="submit" value="@Global.Main_Selection_Search" />
        </div>
    }
</div>
